<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>新增/编辑学生</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>

<div class="container">
    <h1 class="mb-4" th:text="${student == null ? '新增学生' : '编辑学生'}"></h1>
    <form th:action="@{/student/save}" th:object="${student}" method="post">
        <input type="hidden" th:field="*{id}">
        <div class="mb-3">
            <label for="name" class="form-label">姓名</label>
            <input type="text" class="form-control" id="name" th:field="*{name}" placeholder="请输入姓名" required>
        </div>
        <div class="mb-3">
            <label for="gender" class="form-label">性别</label>
            <select class="form-select" id="gender" th:field="*{gender}">
                <option value="M">男</option>
                <option value="F">女</option>
            </select>
        </div>
        <div class="mb-3">
            <label for="classId" class="form-label">班级</label>
            <select class="form-select" id="classId" th:field="*{classId}">
                <option th:each="cls : ${classes}" th:value="${cls.id}" th:text="${cls.name}"></option>
            </select>
        </div>
        <button type="submit" class="btn btn-primary">保存</button>
        <a href="#" th:href="@{/student/list}" class="btn btn-secondary">取消</a>
    </form>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
